#include <iostream>
using namespace std;

/*
【题目 224】定义一个Shape 抽象类，在此基础上派生出Rectangle 和Circle，二者都有
GetAreaO函数计算对象的面积，GetPerimO函数计算对象的周长。
*/

class Shape
{
public:
    virtual double GetArea() = 0;
    virtual double GetPerim() = 0;
};

class Rectangle : public Shape
{
public:
    Rectangle(double l, double w) : length(l), width(w) {}
    double GetArea() { return length * width; }
    double GetPerim() { return 2 * (length + width); }

private:
    double length;
    double width;
};

class Circle : public Shape
{
public:
    Circle(double r) : radius(r) {}
    double GetArea() { return 3.14 * radius * radius; }
    double GetPerim() { return 2 * 3.14 * radius; }

private:
    double radius;
};

int main()
{
    Rectangle rect(3, 4);
    Circle circle(5);

    cout << "Rectangle Area: " << rect.GetArea() << endl;
    cout << "Rectangle Perim: " << rect.GetPerim() << endl;
    cout << "Circle Area: " << circle.GetArea() << endl;
    cout << "Circle Perim: " << circle.GetPerim() << endl;
}